package com.ryskoo.catering.coupondetail.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.coupondetail.domain.CouponDetailPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class CouponDetailRedisImpl extends BasicRedisImpl<CouponDetailPO> implements ICouponDetailRepository {

    private static final String cacheKey = HCLCacheConstant.HCL_COUPONDETAIL_KEY;

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private ICouponDetailRepository couponDetailRepository;

    @PostConstruct
    public void init() {
        this.setRedisClient(redisClient);
        this.setDao(couponDetailRepository);
    }

    public CouponDetailRedisImpl() {
        super(cacheKey);
    }

    @Override
    public List<CouponDetailPO> getListByCustomerUuidAndCouponUuids(String customerUuid, List<String> couponUuids) {
        return couponDetailRepository.getListByCustomerUuidAndCouponUuids(customerUuid, couponUuids);
    }

    @Override
    public List<CouponDetailPO> getListByCustomerUuidAndCouponUuid(String customerUuid, String couponUuid) {
        return couponDetailRepository.getListByCustomerUuidAndCouponUuid(customerUuid, couponUuid);
    }

    @Override
    public List<CouponDetailPO> getCouponDetailList(String customerUuid, String productUuid, double price) {
        return couponDetailRepository.getCouponDetailList(customerUuid, productUuid, price);
    }

    @Override
    public List<CouponDetailPO> getVendorCouponDetailList(String customerUuid, String vendorUuid, double price) {
        return couponDetailRepository.getVendorCouponDetailList(customerUuid, vendorUuid, price);
    }
}
